package com.ruoyi.carShop.service.impl;

import com.ruoyi.carShop.service.LoadService;
import com.ruoyi.carShop.util.JwtUtil;
import io.jsonwebtoken.Claims;
import org.springframework.stereotype.Service;

@Service
public class LoadServiceImpl implements LoadService {


    @Override
    public int getToken(String token) {
        int mId;
        try {
            Claims claims = JwtUtil.parseJWT(token);
            System.out.println(claims.getSubject());
            mId = Integer.parseInt(claims.getSubject());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return mId;
    }
}
